package com.boge.spi;

import com.boge.spi.api.CarApi;

import java.io.IOException;
import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * @Description TODO
 * @Author boge
 * @Date 2024/4/11 13:26
 */
public class TestCar {


    public static void main(String[] args) throws IOException {

//        ClassLoader cl = Thread.currentThread().getContextClassLoader();
//        cl.getResources("META-INF/services/com.boge.spi.api.CarApi");
        new TestCar().testCar();
    }

    public void testCar(){
        ServiceLoader<CarApi> carApis = ServiceLoader.load(CarApi.class);
        Iterator<CarApi> iterator = carApis.iterator();
        while (iterator.hasNext()){
            CarApi next = iterator.next();
            System.out.println(next.builderCar());
        }
    }
}
